#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>

int main()
{
    umask(0000);
    //int fd = open("content.txt", O_CREAT | O_WRONLY | O_TRUNC, 0666);
    //int fd = open("content.txt", O_CREAT | O_WRONLY | O_APPEND, 0666);
    int fd = open("content.txt", O_RDONLY);
    if(fd < 0)
    {
        perror("open");
        return 1;
    }
    while(1)
    {
        char buffer[64];
        memset(buffer, 0, sizeof(buffer));
        int n = read(fd, buffer, sizeof(buffer) - 1);
        if(n > 0)
        {
            printf("%s\n", buffer);
        }
        else if(n == 0)
        {
            break;
        }
        else 
        {
            perror("read");
            return 1;
        }
    }



    //const char* msg = "hello bit\n";
    //int cnt = 5;
    //int a = 1234567;
    //while(cnt)
    //{
    //    //write(fd, msg, strlen(msg));
    //    char buffer[16];
    //    snprintf(buffer, sizeof(buffer), "%d\n", a);
    //    write(fd, buffer, strlen(buffer));
    //    cnt--;
    //}

    close(fd);

    return 0;
}
